using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PeaShooter : Plant
{
    [SerializeField]
    private float ShooterCycle = 2f;
    private float ShooterTimer;


    void Start()
    {
        
    }

    void Update()
    {
        if (curState != PlantState.Planted) return;
        if (ShooterTimer >= ShooterCycle)
        {
            ShooterTimer = 0;
        }
        ShooterTimer += Time.deltaTime;
        if (ShooterTimer >= ShooterCycle)
        {
            Shooter();
        }

    }

    void Shooter()
    {
        GameObject peaBullet = ResourceManager.Instance.PeaBullet;

        Vector3 newPosition =  transform.position; ;

        Instantiate(peaBullet, newPosition, transform.rotation);
    }
}
